{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="mb-20" method="get" action="{:\\think\\Url::build($Request.action)}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="用户" name="realname" value="{$Request.param.realname}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="车牌" name="plate_number" value="{$Request.param.plate_number}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="微信号" name="weixin_no" value="{$Request.param.weixin_no}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="手机号" name="mobile" value="{$Request.param.mobile}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="座位数" name="seats" value="{$Request.param.seats}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="请输入车辆品牌" name="car_brand" value="{$Request.param.car_brand}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="请输入汽车型号"  name="car_model" value="{$Request.param.car_model}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="车类型" name="car_type" value="{$Request.param.car_type}">
        <input type="text" class="input-text" autocomplete="off" style="width:250px" placeholder="请输入民族" name="nationality" value="{$Request.param.nationality}">

        <div   style="width:250px;display: inline-block" >
        <select name="tag" class="select2 " id="tag">
            <option value="">选择标签</option>
            {volist name="driver_tags" id="driver_tag"}
            <option value="{$driver_tag.id}">{$driver_tag['chinese']}</option>
            {/volist}
        </select>

    </div>
        <div   style="width:250px;display: inline-block" >
            <select name="driver_rank_id" class="select2 " id="driver_rank_id">
                <option value="">选择等级</option>
                <option value="5">新手</option>
                {volist name="ranks" id="rank"}
                <option value="{$rank.id}">{$rank.name}</option>
                {/volist}
            </select>
        </div>
        <button type="submit" class="btn btn-success" id="realname_btn" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </form>
    <!--select2 js 插件-->
    <script type="text/javascript" src="__LIB__/select2-4.0.3/dist/js/select2.min.js"></script>
    <!--select2样式 start -->
    <link href="__LIB__/select2-4.0.3/dist/css/select2.min.css" rel="stylesheet" />

    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">

        </span>
        <span class="r pt-5 pr-5">
            共有数据 ：<strong>{$count ?? '0'}</strong> 条
        </span>
    </div>
    <?php use think\Db;?>
    <table class="table table-border table-bordered table-hover table-bg mt-20">
        {php} $public_path = ROOT_PATH."public";{/php}
        <thead>
        <tr class="text-c">
            {include file="th" /}
            <th width="70">操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
        <tr class="text-c">
            {include file="td" /}
            <td class="f-14">
                <a title="添加司机标签" href="javascript:;" onclick="layer_open('添加司机标签','/admin/driver/add_tag/id/{$vo.id}.html')" class="label label-warning radius" >添加标签</a>
                &nbsp;
                <a title="司机银行卡资料" href="javascript:;" onclick="layer_open('司机银行卡资料','/admin/driver/bank_card_info/id/{$vo.id}.html')" class="label label-warning radius" >司机银行卡资料</a>
                &nbsp;&nbsp;
                <!--已通过司机-->
                {if ($vo.check_status == 'checked')}
                <!--<a title="详细资料" href="javascript:;" onclick="layer_open('详细资料','/admin/driver/details/id/{$vo.id}',{w:'1300px',h:'750px'})" style="text-decoration:none" class="ml-5 label label-warning radius">详细资料</a>&nbsp;&nbsp;-->
                <a title="详细资料" href="javascript:;" onclick="driverInfo({$vo.id})" style="text-decoration:none" class="ml-5 label label-warning radius">详细资料</a>&nbsp;&nbsp;
                {/if}
                {switch name="$vo.check_status"}
                {case value="notapply"}
                    <a href="javascript:;" onclick="apply('/admin/driver/apply/user_id/{$vo.user_id}')" class="label label-warning radius" title="申请">申请</a>
                {/case}
                {case value="applying"}
                    <a href="javascript:;" onclick="agree('/admin/driver/agree/user_id/{$vo.user_id}')" class="label label-warning radius" title="通过">通过</a>
                    <a href="javascript:;" onclick="reject('/admin/driver/reject/user_id/{$vo.user_id}')" class="label label-warning radius" title="不通过">不通过</a>
                {/case}
                {case value="checked"}

                <a href="javascript:;" onclick="apply('/admin/driver/apply/user_id/{$vo.user_id}')" class="label label-warning radius" title="重新申请">重新申请</a>
                <a href="javascript:;" onclick="reject('/admin/driver/reject/user_id/{$vo.user_id}')" class="label label-warning radius" title="不通过">不通过</a>
                {/case}
                {default /}

                {/switch}

                <!--{$vo.status|show_status=$vo.id}-->
                {tp:menu menu='sedit' /}
                <!--{tp:menu menu='sdelete' /}-->
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page-bootstrap">{$page ?? ''}</div>
</div>
<script>


    function driverInfo(id) {
        var url = '/admin/driver/details';
        if (!id){
            layer.msg('缺少必要的参数');
        }
        $.ajax({
            type: 'get',
            url: url,
            data:{ id: id },
            success: function (data) {
                if (data.code == 1){
                    layer.msg(data.msg)
                    return false
                }else{
                    layer_open('详细资料','/admin/driver/details/id/'+id,{w:'1300px',h:'750px'})
                 }
            }
        })
    }
    function reject(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if (re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                        btn: [ '知道了']
                    },function () {
                        location.reload()
                    });
            }else{
                 layer_open('不通过','/admin/pub/role/id/1')
                }
            },
        });
    }

    function apply(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if(re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                        btn: ['知道了']
                    }, function () {
                        location.reload()
                    });
                }else{
                    layer_open('申请','/admin/pub/role/id/1')
                }

            },
        });
    }
    function agree(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if(re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                        btn: ['知道了']
                    }, function () {
                        location.reload()
                    });
                }else{
                layer_open('通过','/admin/pub/role/id/1')
                }
            },
        });
    }
    $(function () {
        var tag = $("#tag").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        {notempty name = "Request.param.tag"}
        tag.val("{$Request.param.tag}").trigger("change");
        {/notempty}

        var driver_rank_id = $("#driver_rank_id").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        {notempty name = "Request.param.driver_rank_id"}
        driver_rank_id.val("{$Request.param.driver_rank_id}").trigger("change");
        {/notempty}
        })
</script>
{/block}

